use sugar::*;
use sugar::SResultExt;

fn do_work1() -> Result<i32, String> {
    Ok(1)
}

fn do_work2() -> Result<(), String> {
    // I don't care about the result's Ok value
    do_work1()
        .drop_value()
}

fn return_2() -> i32 {
    return 2;
}

fn main() {
    let result = do_work2().unwrap();
    println!("{:?}",result);

    let fun1=|x:i32| x*3;

    println!("{}",fun1(2));

    // vec construction
    let _v = vec![1, 2, 3];

    // vec of boxed value
    let vb = vec_box![1, 2, 3];

    // hashmap construction
    let hm = hashmap!{
        1 => 2,
        2 => 3,
        3 => 4,
    };

    // list comprehension
    let vb2 = c![Box::new(i), for i in 1..4];
    let vb3 = vec_box![1,2,3];

    assert_eq!(vb, vb2);
    assert_eq!(vb, vb3);

    // hashmap comprehension
    let hm2 = c![i => i + 1, for i in 1..4];
    assert_eq!(hm, hm2);

    assert_eq!(max!(3, 1, 2, 7, 0), 7);
    assert_eq!(min!(3, 1, 2, 7, 0), 0);

    assert_eq!(cmp!(1, < 2, < 3), true);
    assert_eq!(cmp!(1, <= 2, <= 3), true);
    assert_eq!(cmp!(1, <= 2, <= 3, != 4), true);

    // return_2 will not be called
    assert_eq!(cmp!(2, < 1, < 3, < return_2()), false);

    // return_2 will be called once
    assert_eq!(cmp!(1, < return_2(), == 2), true);

    println!("{}","fsafsafdafdsa");
}
